package nx.simple3d.data;

/**
 * Base class for classes which need to store vectors in the vectorbase
 * @author Simon
 *
 */
public abstract class VectorHandler {
  protected VectorBase vb;
  protected int vbOffset;
  
  /**
   * The base constructor needs to know the vectorbase in order to manage
   * the memory reservation.
   * @param vb The underlying vectorbase
   */
  public VectorHandler(){
    vb = VectorBase.getInstance();
    vb.registerVectorHandler(this);
  }
  
  /**
   * This method is called by the vectorbase once it knows at which address the data of
   * this vectorhandler can be stored.
   * @param offset The first address of the reserved vector memory
   */
  public void setVectorOffset(int vbOffset){
    this.vbOffset = vbOffset;
  }
  
  /**
   * @return The first address of the reserved vector memory in the vectorbase
   */
  public int getVectorOffset(){
    return vbOffset;
  }
  
  /**
   * This method shall return the number of vectors which this vectorhandler provides
   * @return The number of vectors provided
   */
  public abstract int getRequiredVectorCacheSize();
  
  /**
   * This method is called to write the vectors to the vectorbase
   */
  public abstract void initializeVectorData();
}
